import 'package:flutter/material.dart';
import 'package:lai_zhan/common/model/userResult/user_result.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:redux/redux.dart';
import 'package:lai_zhan/common/redux/AppState.dart';
import 'package:lai_zhan/page/WelcomePage.dart';
import 'package:lai_zhan/page/LoginPage.dart';
import 'package:lai_zhan/common/style/AppStyle.dart';
import 'package:lai_zhan/page/RegisterPage.dart';
import 'package:lai_zhan/page/CompleteUserInfoPage.dart';
import 'package:lai_zhan/page/IndexPage.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  final Store<AppState> store = new Store<AppState>(appReducer,
      initialState: new AppState(userInfo: UserResult.empty(), shops: new List()));

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new StoreProvider(
        store: store,
        child: new StoreConnector<AppState, AppState>(
            builder: (context, state) {
              return new MaterialApp(
                theme: new ThemeData(primaryColor: Color(AppColors.primaryColor),
                    //scaffoldBackgroundColor: Color(AppColors.primaryColor),
                ),
                color: Color(AppColors.lightWhite),
                routes: {
                  WelcomePage.rName: (context) => new WelcomePage(),
                  LoginPage.rName: (context) => new LoginPage(),
                  RegisterPage.rName: (context) => new RegisterPage(),
                  CompleteUserInfoPage.rName:(context) => new CompleteUserInfoPage(),
                  IndexPage.rName:(context) => new IndexPage(),
                },
              );
            },
            converter: (state) => store.state));
  }
}
